//
//  UIButton+Expand.m
//  CJRailTransport
//
//  Created by Hank on 2018/1/13.
//  Copyright © 2018年 amplity. All rights reserved.
//

#import "UIButton+Expand.h"

@implementation UIButton (Expand)
// 设置按钮圆角
- (void)radiusBtn:(CGFloat)radius backgroundColor:(UIColor *)backgroundColor borderWidth:(CGFloat)borderWidth borderColor:(UIColor *)borderColor
{
    // 设置圆角
    self.layer.cornerRadius = radius;
    self.layer.backgroundColor = backgroundColor.CGColor;
    self.layer.borderWidth = borderWidth;
    self.layer.borderColor = borderColor.CGColor;
}
// 设置Item左右菜单按钮
+ (UIButton *)setLeftOrRightButton:(NSString *)imageName direction:(NSString *)direction title:(NSString *)title
{
    UIButton *menuButton = [UIButton buttonWithType:UIButtonTypeCustom];
    if (imageName != nil) {
        [menuButton setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
        if ([direction  isEqual: @"left"]) {
            menuButton.imageEdgeInsets = UIEdgeInsetsMake(5, 0, 5, 10);
        }else{
            menuButton.imageEdgeInsets = UIEdgeInsetsMake(5, 10, 5, 0);
        }
        menuButton.bounds = (CGRect) {CGPointZero,CGSizeMake(35, 35)};
    }else{
        menuButton.bounds = (CGRect) {CGPointZero,CGSizeMake(40, 35)};
    }
    [menuButton setTitle:title forState:UIControlStateNormal];
    [menuButton setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
    menuButton.backgroundColor = [UIColor clearColor];
    menuButton.titleLabel.font = Text_Font(16);
    menuButton.titleLabel.textAlignment = NSTextAlignmentRight;
    //    if ([direction  isEqual: @"left"]) {
    //        self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:menuButton];
    //    }else{
    //        self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:menuButton];
    return menuButton;
}

@end
